// pages/choiceSite/choiceSite.js
var QQMapWX = require("../../../sdk/qqmap-wx-jssdk.min.js");

var common = require("../../../common/common.js").common;

Page({
    /**
   * 页面的初始数据
   */
    data: {
        name: ""
    },
    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function(options) {
        let that = this;
        if (options.search_con) {
            that.setData({
                name: options.search_con
            });
        }
        that.getCityList();
    },
    /**
   * 生命周期函数--监听页面初次渲染完成
   */
    onReady: function() {},
    /**
   * 生命周期函数--监听页面显示
   */
    onShow: function() {},
    /**
   * 生命周期函数--监听页面隐藏
   */
    onHide: function() {},
    /**
   * 生命周期函数--监听页面卸载
   */
    onUnload: function() {},
    /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
    onPullDownRefresh: function() {},
    /**
   * 页面上拉触底事件的处理函数
   */
    onReachBottom: function() {},
    /**
   * 用户点击右上角分享
   */
    onShareAppMessage: function() {},
    getCityList: function() {
        let that = this;
        common.request({
            endpoint: "DIY/new-entry/city-list",
            method: "post",
            data: {
                name: that.data.name
            },
            header: {},
            success: function(res) {
                that.setData({
                    cityList: res.extra
                });
            }
        });
    },
    //记录搜索名称
    saveWord: function(e) {
        var that = this;
        var search_con = e.detail.value;
        that.setData({
            name: search_con
        });
    },
    goToDetail(e) {
        wx.setStorageSync("uniacid", e.currentTarget.dataset.uniacid);
        wx.navigateTo({
            url: e.currentTarget.dataset.url
        });
    }
});